import java.time.chrono.IsoChronology;
import java.util.*;

/**
 * @author starsea
 * @date 2024-02-19 20:37
 */

public class Main {
    public static void main(String[] args) {
        //int c=minAddToMakeValid("()(");
        //int c=kthFactor(12,3);
        String s = "bbaA";
        //List ret=letterCasePermutation(s);
        String str=frequencySort(s);
    }
    public static String frequencySort(String s) {
       Map<Character,Integer> map=new TreeMap<>();
       for(int i=0;i<s.length();i++)
       {
           int index=1;
           if(map.containsKey(s.charAt(i)))
           {
               index+=1;
           }
           map.put(s.charAt(i),index);
       }
      return null;

    }
    //存储所有结果
    static List<String>ret;
    //存储路径
    static StringBuffer path;
    static  String str;
    public static List<String> letterCasePermutation(String s) {
        ret=new ArrayList<>();
        path=new StringBuffer();
        str=s;
         dfs(0);
         return ret;

    }
    public static void dfs(int post)
    {
            if(post==str.length())
            {
                ret.add(path.toString());
                return;
            }
            //变

            //不变
            char ch=str.charAt(post);
            path.append(ch);
            dfs(post+1);
            path.deleteCharAt(path.length()-1);

    }

    public static int kthFactor(int n, int k) {
        if(k==1) {return 1;}
        int i=2;
        while (k!=0 && n>=i)
        {
            if(n%i==0) {k--;}
            if(k==1) {return i;}
            i++;
        }
        return -1;

    }
    public static int minAddToMakeValid(String s) {
        if(s.length()<=0)
        {
            return 0;
        }
        Stack<Character> stack=new Stack<>();
        for(int i=0;i<s.length();i++)
        {
            char ch=s.charAt(i);
            if(stack.isEmpty())
            {
                stack.push(ch);
            }
            else
            {
                if(stack.peek()=='(' && ch==')')
                {
                    stack.pop();
                }
                else
                {
                    stack.push(ch);
                }
            }
        }
        return stack.size();

    }
}